/*esp8266UDP上电初始化进入UDB透传模式*/

#include "stc15.h"
#include "esp8266ini.h"
                      
unchar cwmode[]={41 54 2B 43 57 4D 4F 44 45 3D 31};//AT+CWMODE=1 
unchar rst[]={41 54 2B 52 53 54 };//AT+RST  
//AT+CWJAP_DEF="Tenda_3CC0D8","77881234"  
unchar cwjap[]={41 54 2B 43 57 4A 41 50 5F 44 45 46 3D 22 54 65 6E 64 61 5F 33 43 43 30 44 38 22 2C 22 37 37 38 38 31 32 33 34 22};                          
unchar cipmux[]={41 54 2B 43 49 50 4D 55 58 3D 30 };//AT+CIPMUX=0　　　　　　　　　　　　　　　
unchar cipmode[]={41 54 2B 43 49 50 4D 4F 44 45 3D 31};//AT+CIPMODE=1　
//AT+CIPSTART="UDP","255.255.255.255",5000,5002
unchar cipstart[]={41 54 2B 43 49 50 53 54 41 52 54 3D 22 55 44 50 22 2C 22 32 35 35 2E 32 35 35 2E 32 35 35 2E 32 35 35 22 2C 35 30 30 30 2C 35 30 30 32};　　　　　　
unchar cipsend[]={41 54 2B 43 49 50 53 45 4E 44};//AT+CIPSEND　


void delay();

void esp8266ini(void)
{
    trsP = cwmode;
    trsLen = 11;
    TI =1;
    delay(10); 

    trsP = rst;
    trsLen = 6;
    TI =1;
    delay(50);

    trsP = cipmux;
    trsLen = 11;
    TI =1;
    delay(10); 

    trsP = cipmode;
    trsLen = 12;
    TI =1;
    delay(10);
        
    trsP = cipstart;
    trsLen = 45;
    TI =1;
    delay(50); 

    trsP = cipsend;
    trsLen = 10;
    TI =1;
    delay(5);
                            
}
    

void delay(unsigned int x) //延时单位MS
{
    unsigned int i,j;
    for(i=x;i>0;i--)
    for(j=110;j>0;j--);
}    